package com.ac.utils;

import java.util.ArrayList;
import java.util.List;
public class CutUtil {

    public static List<String> splitByVHash(String input) {
        List<String> result = new ArrayList<>();
        StringBuilder currentSection = new StringBuilder();

        for (int i = 0; i < input.length(); i++) {
            // 检查是否遇到了"V_#"标识符
            if (i + 2 < input.length() && input.charAt(i) == 'V' && input.charAt(i + 1) == '_' && input.charAt(i + 2) == '#') {
                // 如果currentSection不为空，将其添加到结果列表中
                if (currentSection.length() > 0) {
                    result.add(currentSection.toString());
                }
                // 清空currentSection以准备存储下一个部分
                currentSection.setLength(0);
                i += 2; // 跳过"V_#"
            } else {
                // 如果不是"V_#"，则继续构建当前部分
                currentSection.append(input.charAt(i));
            }
        }

        if (currentSection.length() > 0) {
            result.add(currentSection.toString());
        }

        return result;
    }

    public static List<String> getCut(String input){
        List<String> sections = splitByVHash(input);
        return sections;
    }
}
